package com.hl.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.hl.order.domain.Vip;
import com.hl.order.service.IVipService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 会员表Controller
 * 
 * @author ruoyi
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/vip")
public class VipController extends BaseController
{
    @Autowired
    private IVipService vipService;

    /**
     * 查询会员表列表
     */
    @RequiresPermissions("order:vip:list")
    @GetMapping("/list")
    public TableDataInfo list(Vip vip)
    {
        startPage();
        List<Vip> list = vipService.selectVipList(vip);
        return getDataTable(list);
    }

    /**
     * 导出会员表列表
     */
    @RequiresPermissions("order:vip:export")
    @Log(title = "会员表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Vip vip)
    {
        List<Vip> list = vipService.selectVipList(vip);
        ExcelUtil<Vip> util = new ExcelUtil<Vip>(Vip.class);
        util.exportExcel(response, list, "会员表数据");
    }

    /**
     * 获取会员表详细信息
     */
    @RequiresPermissions("order:vip:query")
    @GetMapping(value = "/{vipId}")
    public AjaxResult getInfo(@PathVariable("vipId") Long vipId)
    {
        return success(vipService.selectVipByVipId(vipId));
    }

    /**
     * 新增会员表
     */
    @RequiresPermissions("order:vip:add")
    @Log(title = "会员表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Vip vip)
    {
        return toAjax(vipService.insertVip(vip));
    }

    /**
     * 修改会员表
     */
    @RequiresPermissions("order:vip:edit")
    @Log(title = "会员表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Vip vip)
    {
        return toAjax(vipService.updateVip(vip));
    }

    /**
     * 删除会员表
     */
    @RequiresPermissions("order:vip:remove")
    @Log(title = "会员表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vipIds}")
    public AjaxResult remove(@PathVariable Long[] vipIds)
    {
        return toAjax(vipService.deleteVipByVipIds(vipIds));
    }
}
